package main

import (
	"fmt"
	"net"
	"time"
)

func main() {
	fmt.Println("client start...")

	time.Sleep(time.Second)

	conn, err := net.Dial("tcp4", "127.0.0.1:8999")
	if err != nil {
		fmt.Println("net.Dial error:", err)
	}

	for {
		_, err := conn.Write([]byte("hello Zinx V0.1"))
		if err != nil {
			fmt.Println("write conn error:", err)
		}

		buf := make([]byte, 512)
		cnt, err := conn.Read(buf)
		if err != nil {
			fmt.Println("read conn buf error:", err)
			continue
		}

		fmt.Printf("server call back: %s, cnt = %d\n", buf, cnt)

		time.Sleep(time.Second)
	}
}
